package com.anXin.article.service.impl;

import com.anXin.article.mapper.ArticleConfigMapper;
import com.anXin.article.service.ArticleConfigService;
import com.anXin.model.article.pojos.ArticleConfig;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

@Service
@Slf4j
@Transactional
public class ArticleConfigServiceImpl extends ServiceImpl<ArticleConfigMapper, ArticleConfig> implements ArticleConfigService {
    /**
     * 修改文章
     * @param map
     */
    @Override
    public void updateByMap(Map map) {
        //0下架1上架
        Object enable = map.get("enable");
        boolean isDown=true;
        if (enable.equals(1)){
            isDown=false;
        }
        //修改文章
        update(Wrappers.<ArticleConfig>lambdaUpdate()
                .eq(ArticleConfig::getArticleId,map.get("articleId")).set(ArticleConfig::getIsDown,isDown));
    }
}
